package org.devocean.groupbuying.domain;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;

@SuppressWarnings("serial")
@Entity
public class ArticlesLocalization implements Serializable {

	@Id
	@GeneratedValue
	private Integer articlesLocalizationID;
	
	private String permalink;

	@ManyToMany(fetch = FetchType.LAZY)
	@JoinTable(name = "ac_localization", joinColumns = { @JoinColumn(name = "articlesLocalizationID", referencedColumnName = "articlesLocalizationID") }, inverseJoinColumns = { @JoinColumn(name = "categoriesLocalizationID", referencedColumnName = "categoriesLocalizationID") })
	private Set<CategoriesLocalization> categoriesLocalizations = new HashSet<CategoriesLocalization>();

	@ManyToMany(fetch = FetchType.LAZY )
	@JoinTable(name = "am_localization", joinColumns = { @JoinColumn(name = "articlesLocalizationID", referencedColumnName = "articlesLocalizationID") }, inverseJoinColumns = { @JoinColumn(name = "MediaID", referencedColumnName = "MediaID") })
	private Set<Media> mediaLocalizations = new HashSet<Media>();


	@OneToMany(cascade = CascadeType.ALL, mappedBy = "articlesLocalization", fetch = FetchType.LAZY)
	private Set<Article> articles = new HashSet<Article>();

	@ManyToMany(fetch = FetchType.LAZY)
	@JoinTable(name = "tags_localization", joinColumns = { @JoinColumn(name = "articlesLocalizationID", referencedColumnName = "articlesLocalizationID") }, inverseJoinColumns = { @JoinColumn(name = "tagsID", referencedColumnName = "tagsID") })
	private Set<Tags> tags = new HashSet<Tags>();

	public Integer getArticlesLocalizationID() {
		return articlesLocalizationID;
	}


	public void setArticlesLocalizationID(Integer articlesLocalizationID) {
		this.articlesLocalizationID = articlesLocalizationID;
	}

	public Set<Article> getArticles() {
		return articles;
	}

	public void setArticles(Set<Article> articles) {
		this.articles = articles;

	}

	public Set<CategoriesLocalization> getCategoriesLocalizations() {
		return categoriesLocalizations;
	}

	public void setCategoriesLocalizations(
			Set<CategoriesLocalization> categoriesLocalizations) {
		this.categoriesLocalizations = categoriesLocalizations;
	}

	public Set<Media> getMediaLocalizations() {
		return mediaLocalizations;
	}

	public void setMediaLocalizations(Set<Media> mediaLocalizations) {
		this.mediaLocalizations = mediaLocalizations;
	}

	public Set<Tags> getTags() {
		return tags;
	}

	public void setTags(Set<Tags> tags) {
		this.tags = tags;
	}

	public String getPermalink() {
		return permalink;
	}

	public void setPermalink(String permalink) {
		this.permalink = permalink;
	}

	@Override
	public String toString() {
		return "ArticlesLocalization [articlesLocalizationID=]";
	}
	

}
